<template>
<div id="addressmanage">
<NavBar>
  <div slot="left" class="left" @click="return_before"><van-icon name="arrow-left" /></div>
  <div slot="center">地址管理</div>
</NavBar>
<div>
<van-address-list
  v-model="chosenAddressId"
  :list="list"
  default-tag-text="默认"
  @add="onAdd"
  @edit="onEdit"
/>
</div>
</div>
</template>

<script>
import NavBar from "@/components/common/NavBar/NavBar";
import {get_address} from "@/network/Users/get_address";

export default {
name: "address",
  components:{NavBar},
   data() {
    return {
    chosenAddressId: '1',
      list: [
        // {
        //   id: '1',
        //   name: '张三',
        //   tel: '13000000000',
        //   address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        //   isDefault: true,
        // },
        // {
        //   id: '2',
        //   name: '李四',
        //   tel: '1310000000',
        //   address: '浙江省杭州市拱墅区莫干山路 50 号',
        // }]
      ]
    };
  },
  methods: {
  return_before(){
    history.go(-1)
  },
      onAdd() {
      this.$toast('新增地址');
       this.$router.push('/address_increase')
    },
    onEdit(item, index) {
       this.$toast('编辑地址'+index);
       this.$router.push('/address')
    },
  },
created() {
  get_address().then(
      res=>{
       this.list=res.addresses;
      }
  )
}
}
</script>

<style scoped>
.left .van-icon {
    font-size: 20px;
    position: relative;
    top: 3px;
    left: -8px;
}
#addressmanage{
  background-color: rgb(247,248,250);
  height: 1000px;
}
</style>